package rankingGenerator.statistics;

public class KUsefulWithProbability implements DREComparableStatistic {

	private int k;
	private double prob;

	public KUsefulWithProbability(int bestK, double bestProbability) {
		
		k = bestK;
		prob = bestProbability;
		
	}

	public int compareTo(DREComparableStatistic o1) {
		
		KUsefulWithProbability o = (KUsefulWithProbability)o1;
		
		if (k>o.k)
			return 1;
		else if (k < o.k)
			return -1;
		else{
			//same K value. When K is 0 we revert the comparison
			
			if (k!=0){
				
				if (prob > o.prob)
					return 1;
				else if (prob < o.prob)
					return -1;
				else
					return 0;
			
			}else{
				
				if (prob > o.prob)
					return -1;
				else if (prob < o.prob)
					return 1;
				else
					return 0;
				
			}
		}
		
	}

	public String toString(){
		return Double.toString(k);
	}
	
}
